<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html>
<html lang="en">
<script src="${ctx}/static/healthassess/js/jquery-2.1.4.min.js"></script>
<script src="${ctx}/static/inspinia/js/plugins/layer/layer.js"></script>
<script src="${ctx}/static/h5/js/initRem.js"></script>
<head>
    <title>问卷</title>
    <%@ include file="/jsp/common.jsp"%>
    <link href="${ctx}/static/h5/css/base.css" rel="stylesheet">
    <link href="${ctx}/static/h5/css/q-style.css" rel="stylesheet">
</head>
<body class="bg-cf">
    <section class="ui-content">
        <div class="content-block padding-l-0 padding-r-0 padding-t-0 margin-b-0">
            <div class="questions-m">
                <div class="test-m">
                    <form method="get" data-ajax="${ctx}/main" action="${ctx}/h5/problem/save"  class="form-horizontal" id="problem_form">
                    <div id="Problem">
                        <h1>一、基本信息</h1>
                            <div class="text-info-list">
                                <section class="question-list-m q-list-w">
                                    <h3>1、性别</h3>                        
                                    <ul>
                                        <li><input class="i-checkbox" type="radio" name="sexRadio" value="0"><span>男</span></li>
                                        <li><input class="i-checkbox" type="radio" name="sexRadio" value="1"><span>女</span></li>
                                    </ul>
                                </section>
                                <section class="question-list-m q-list-w">
                                    <h3>2、年龄</h3>                        
                                    <ul>
                                        <li><input class="i-checkbox" type="radio" name="ageRadio" value="0"><span>18-25岁</span></li>
                                        <li><input class="i-checkbox" type="radio" name="ageRadio" value="1"><span>26-34岁</span></li>
                                        <li><input class="i-checkbox" type="radio" name="ageRadio" value="2"><span>35-45岁</span></li>
                                        <li><input class="i-checkbox" type="radio" name="ageRadio" value="3"><span>46-54岁</span></li>
                                        <li><input class="i-checkbox" type="radio" name="ageRadio" value="4"><span>>55岁</span></li>
                                    </ul>
                                </section>
                                <section class="question-list-m">
                                    <h3>3、身高(厘米)</h3>                        
                                     <ul><div class="input-w-box"><input class="" name="height" type="text"  value=""/></div></ul>
                                </section>
                                <section class="question-list-m">
                                    <h3>4、体重(公斤)</h3>                        
                                    <ul><div class="input-w-box"><input class="" name="weight" type="text"  value=""/></div></ul>
                                </section>
                            </div>
                        <h1>二、个人现状</h1>
                          <div class="text-info-list">
                             <section class="question-list-m">
                                    <h3>1、请在下列符合您现状的选项上打勾（可多选）</h3>                        
                                    <ul>
                                        <li><input class="i-more-checkbox" type="checkbox" name="qxCheckbox" value="0"><span>缺乏运动</span></li>
                                        <li><input class="i-more-checkbox" type="checkbox" name="qxCheckbox" value="1"><span>熬夜</span></li>
                                        <li><input class="i-more-checkbox" type="checkbox" name="qxCheckbox" value="2"><span>吸烟</span></li>
                                        <li><input class="i-more-checkbox" type="checkbox" name="qxCheckbox" value="3"><span>饮酒</span></li>
                                        <li><input class="i-more-checkbox" type="checkbox" name="qxCheckbox" value="4"><span>味偏咸</span></li>
                                        <li><input class="i-more-checkbox" type="checkbox" name="qxCheckbox" value="5"><span>肥胖</span></li>
                                    </ul>
                              </section>
                              <section class="question-list-m">
                                    <h3>2、您经常参加体育锻炼吗？</h3>                        
                                    <ul>
                                        <li><input class="i-checkbox" type="radio" name="dlRadio" value="0"><span>每天锻炼</span></li>
                                        <li><input class="i-checkbox" type="radio" name="dlRadio" value="1"><span>每周锻炼3-5天</span></li>
                                        <li><input class="i-checkbox" type="radio" name="dlRadio" value="2"><span>偶尔锻炼</span></li>
                                        <li><input class="i-checkbox" type="radio" name="dlRadio" value="3"><span>从不锻炼</span></li>
                                    </ul>
                              </section>
                              <section class="question-list-m">
                                    <h3>3、您认为您目前的身体状况是：</h3>                        
                                    <ul>
                                        <li><input class="i-checkbox" type="radio" name="stzkRadio" value="0"><span>健康</span></li>
                                        <li><input class="i-checkbox" type="radio" name="stzkRadio" value="1"><span>亚健康</span></li>
                                        <li><input class="i-checkbox" type="radio" name="stzkRadio" value="2"><span>怀疑患病</span></li>
                                        <li><input class="i-checkbox" type="radio" name="stzkRadio" value="3"><span>患病</span></li>
                                    </ul>
                              </section>
                          </div>
                        <h1>三、健康企业创建意见与建议</h1>
                        <div class="text-info-list">
                            <section class="question-list-m">
                                    <h3>1、您喜欢的健康促进方式有：（可多选）</h3>                        
                                    <ul>
                                        <li><input class="i-more-checkbox" type="checkbox" name="jkcjCheckbox" value="0"><span>健康讲座</span></li>
                                        <li><input class="i-more-checkbox" type="checkbox" name="jkcjCheckbox" value="1"><span>义诊咨询</span></li>
                                        <li><input class="i-more-checkbox" type="checkbox" name="jkcjCheckbox" value="2"><span>健康教育折页</span></li>
                                        <li><input class="i-more-checkbox" type="checkbox" name="jkcjCheckbox" value="3"><span>版面巡展</span></li>
                                        <li><input class="i-more-checkbox" type="checkbox" name="jkcjCheckbox" value="4"><span>流动健康驿站</span></li>
                                        <li><input class="i-more-checkbox" type="checkbox" name="jkcjCheckbox" value="5"><span>健康评比</span></li>
                                        <li><input class="i-more-checkbox" type="checkbox" name="jkcjCheckbox" value="6"><span>微信发布</span></li>
                                        <li><input class="i-more-checkbox" type="checkbox" name="jkcjCheckbox" value="7"><span>其他</span></li>
                                    </ul>
                            </section>
                            <section class="question-list-m">
                                    <h3>2、您最希望了解哪些知识？（可多选）</h3>                        
                                    <ul>
                                        <li><input class="i-more-checkbox" type="checkbox" name="ljzsCheckbox" value="0"><span>职业安全</span></li>
                                        <li><input class="i-more-checkbox" type="checkbox" name="ljzsCheckbox" value="1"><span>疾病防治</span></li>
                                        <li><input class="i-more-checkbox" type="checkbox" name="ljzsCheckbox" value="2"><span>健康合理饮食</span></li>
                                        <li><input class="i-more-checkbox" type="checkbox" name="ljzsCheckbox" value="3"><span>健康运动</span></li>
                                        <li><input class="i-more-checkbox" type="checkbox" name="ljzsCheckbox" value="4"><span>妇女儿童保健</span></li>
                                        <li><input class="i-more-checkbox" type="checkbox" name="ljzsCheckbox" value="5"><span>中医养生</span></li>
                                        <li><input class="i-more-checkbox" type="checkbox" name="ljzsCheckbox" value="6"><span>心理咨询</span></li>
                                        <li><input class="i-more-checkbox" type="checkbox" name="ljzsCheckbox" value="7"><span>用药知识</span></li>
                                    </ul>
                            </section>
                            <section class="question-list-m">
                                    <h3>3、您希望多久开展一次健康促进活动？</h3>                        
                                    <ul>
                                        <li><input class="i-checkbox" type="radio" name="jkzjhdRadio" value="0"><span>一月1次</span></li>
                                        <li><input class="i-checkbox" type="radio" name="jkzjhdRadio" value="1"><span>一季度1次</span></li>
                                        <li><input class="i-checkbox" type="radio" name="jkzjhdRadio" value="2"><span>半年1次</span></li>
                                        <li><input class="i-checkbox" type="radio" name="jkzjhdRadio" value="3"><span>其他</span></li>
                                    </ul>
                            </section>
                            <section class="question-list-m q-list-w">
                                    <h3>4、您对单位现阶段开展的健康促进活动是否满意：</h3>                        
                                    <ul>
                                        <li><input class="i-checkbox" type="radio" name="sfmyRadio" value="0"><span>非常满意</span></li>
                                        <li><input class="i-checkbox" type="radio" name="sfmyRadio" value="1"><span>比较满意</span></li>
                                        <li><input class="i-checkbox" type="radio" name="sfmyRadio" value="2"><span>不满意</span></li>
                                    </ul>
                            </section>
                            <section class="question-list-m">
                                    <h3>5、您对单位健康促进活动有什么意见和建议：</h3>                        
                                    <ul>
                                      <div class="input-w-box">
                                          <textarea rows="1" name="yj"></textarea>
                                      </div>  
                                    </ul>
                            </section>
                        </div>
                    </div>
                        <input type="hidden" name="sex"/>
                        <input type="hidden" name="age"/>
                        <input type="hidden" name="dl"/>
                        <input type="hidden" name="stzk"/>
                        <input type="hidden" name="jkzjhd"/>
                        <input type="hidden" name="sfmy"/>
                        <input type="hidden" name="qx"/>
                        <input type="hidden" name="jkcj"/>
                        <input type="hidden" name="ljzs"/>

                    <%--<p class="b-smg">谢谢您的支持与参与！</p>--%>
                    </form>
                </div>
                <div class="ui-btn-wrapper test-btn"><input type="button" class="ui-btn ui-btn-submit" id="submit-btn" onclick="save()" value="保存" /></div>
            </div>
           
        </div>
    </section>


    <script>
        function dataCheck() {
            if($("[name='sex']").val() == null || $("[name='sex']").val() == ""){
                layer.msg('请输入性别！');
                return false;
            }
            if($("[name='age']").val() == null || $("[name='age']").val() == ""){
                layer.msg('请输入年龄！');
                return false;
            }
            if($("[name='height']").val() == null || $("[name='height']").val() == ""){
                layer.msg('请输入身高！');
                return false;
            }
            if($("[name='weight']").val() == null || $("[name='weight']").val() == ""){
                layer.msg('请输入体重！');
                return false;
            }
            if($("[name='dl']").val() == null || $("[name='dl']").val() == ""){
                layer.msg('有题目未填写！');
                return false;
            }
            if($("[name='stzk']").val() == null || $("[name='stzk']").val() == ""){
                layer.msg('有题目未填写！');
                return false;
            }
            if($("[name='jkzjhd']").val() == null || $("[name='jkzjhd']").val() == ""){
                layer.msg('有题目未填写！');
                return false;
            }
            if($("[name='sfmy']").val() == null || $("[name='sfmy']").val() == ""){
                layer.msg('有题目未填写！');
                return false;
            }
            if($("[name='qx']").val() == null || $("[name='qx']").val() == ""){
                layer.msg('有题目未填写！');
                return false;
            }
            if($("[name='jkcj']").val() == null || $("[name='jkcj']").val() == ""){
                layer.msg('有题目未填写！');
                return false;
            }
            if($("[name='ljzs']").val() == null || $("[name='ljzs']").val() == ""){
                layer.msg('有题目未填写！');
                return false;
            }
            return true;
        }

        function save(){
            var sex = $('input:radio[name="sexRadio"]:checked').val();
            $("[name='sex']").val(sex);
            var age = $('input:radio[name="ageRadio"]:checked').val();
            $("[name='age']").val(age);
            var dl = $('input:radio[name="dlRadio"]:checked').val();
            $("[name='dl']").val(dl);
            var stzk = $('input:radio[name="stzkRadio"]:checked').val();
            $("[name='stzk']").val(stzk);
            var jkzjhd = $('input:radio[name="jkzjhdRadio"]:checked').val();
            $("[name='jkzjhd']").val(jkzjhd);
            var sfmy = $('input:radio[name="sfmyRadio"]:checked').val();
            $("[name='sfmy']").val(sfmy);


            var qx = "";
            $("input[name='qxCheckbox']:checkbox:checked").each(function(){
                qx = qx + $(this).val() +",";
            });
            if (qx != '') {
                qx =  qx.substring(0,qx.length - 1);
            }
            $("[name='qx']").val(qx);

            var jkcj = "";
            $("input[name='jkcjCheckbox']:checkbox:checked").each(function(){
                jkcj = jkcj + $(this).val() +",";
            });
            if (jkcj != '') {
                jkcj =  jkcj.substring(0,jkcj.length - 1);
            }
            $("[name='jkcj']").val(jkcj);

            var ljzs = "";
            $("input[name='ljzsCheckbox']:checkbox:checked").each(function(){
                ljzs = ljzs + $(this).val() +",";
            });
            if (ljzs != '') {
                ljzs =  ljzs.substring(0,ljzs.length - 1);
            }
            $("[name='ljzs']").val(ljzs);

            var height = $("[name='height']").val();
            var weight = $("[name='weight']").val();
            var yj = $("[name='yj']").val();

            if (!dataCheck()) {
                return;
            }
            $.ajax({
                type: "POST",
                url: "${ctx}/h5/question/save",
                data : {
                    "sex" : sex,"age" : age,"height" : height,"weight" : weight,"dl" : dl,"stzk" : stzk,"jkzjhd" : jkzjhd,"sfmy" : sfmy,"yj" : yj,"qx" : qx,"jkcj" : jkcj,"ljzs" : ljzs,"id": '${rid}'
                },
                success: function(data){
                    console.log("成功");
                    window.location.href = '${ctx}/h5/question/user/list?rid=${rid}&companyId=${companyId}';
                }
            });
        }

    </script>


</body>

</html>